// Created by WXX on 2021/12/14 21:25
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * 执行用时：0 ms, 在所有 C++ 提交中击败了100.00%的用户
 * 内存消耗：7.9 MB, 在所有 C++ 提交中击败了56.43%的用户
 */
class Solution {
public:
    int heightChecker(vector<int> &a) {
        auto b = a;
        sort(b.begin(), b.end());
        int res = 0;
        for (int i = 0; i < a.size(); i++) res += a[i] != b[i];
        return res;
    }
};

int main() {

    vector<int> heights = {1, 1, 4, 2, 1, 3};
    cout << Solution().heightChecker(heights) << endl;  // 3

    return 0;
}
